#/usr/bin/python3
import os
from datetime import datetime
import random
from time import sleep

while True:
    rnum = random.randint(1, 4)
    if rnum==3:
        os.system("python D:\pythontest\\baidu\search.py")

    # 日期格式话模版
    format_pattern = "%H:%M:%S"
    
    end_date = datetime.now()
    end_date = end_date.strftime(format_pattern)
    end_date = datetime.strptime(end_date, format_pattern)
    # 将 'datetime.datetime' 类型时间通过格式化模式转换为 'str' 时间
    if   end_date > datetime.strptime('11:00:00', format_pattern) and end_date < datetime.strptime('13:00:00', format_pattern) :
        sleep(random.randint(1500, 3000))
    elif end_date > datetime.strptime('17:00:00', format_pattern) and end_date < datetime.strptime('21:00:00', format_pattern) :
        sleep(random.randint(1500, 3000))
    elif end_date > datetime.strptime('21:00:00', format_pattern) and end_date < datetime.strptime('23:59:00', format_pattern) :
        sleep(random.randint(2500, 4000))
    else:
        sleep(random.randint(2500, 4000))
